{extend name="$_admin_base_layout" /}

{block name="content"}
    <div class="row">
        <div class="col-md-12">
            <div class="block">
                <div class="block-header bg-gray-lighter">
                    <ul class="block-options">
                        <li>
                            <button type="button" data-toggle="block-option" data-action="refresh_toggle" data-action-mode="demo"><i class="si si-refresh"></i></button>
                        </li>
                        <li>
                            <button type="button" data-toggle="block-option" data-action="fullscreen_toggle"><i class="si si-size-fullscreen"></i></button>
                        </li>
                    </ul>
                    <h3 class="block-title">会员信用额度</h3>
                </div>
                <div class="block-content tab-content">
                    <div class="tab-pane active">
                        <div class="block-content">
                            <form class="form-horizontal form-builder row" name="form-builder" action="/admin.php/capital/creditlimit/creditlimit_save.html" method="post">

                                <div class="form-group hidden " id="form_group_id">
                                    <input type="hidden" name="id" value="{$data.id}" class="form-control" id="id">
                                </div>

                                <div class="form-group col-md-2 " id="form_group_company">
                                    <label class="col-xs-12" for="company">会员名称</label>
                                    <div class="col-sm-12">
                                        <div class="form-control-static">{$data.name}</div>
                                    </div>
                                </div>

                                <div class="form-group col-md-2 " id="form_group_name">
                                    <label class="col-xs-12" for="name">联系人</label>
                                    <div class="col-sm-12">
                                        <div class="form-control-static">{$data.name}</div>
                                    </div>
                                </div>

                                <div class="form-group col-md-3 " id="form_group_mobile">
                                    <label class="col-xs-12" for="mobile">手机号</label>
                                    <div class="col-sm-12">
                                        <div class="form-control-static">{$data.mobile}</div>
                                    </div>
                                </div>

                                <div class="form-group col-md-3 " id="form_group_now_creditlimit">
                                    <label class="col-xs-12" for="now_creditlimit">现有固定额度</label>
                                    <div class="col-sm-12">
                                        <div class="form-control-static" id="now_creditlimit">{$data.creditlimit}</div>
                                    </div>
                                </div>

                                <div class="form-group col-md-4 " id="form_group_creditlimit">
                                    <label class="col-xs-12" for="creditlimit">固定额度修改</label>
                                    <div class="col-sm-12">
                                        <input class="form-control" type="text" id="creditlimit" name="creditlimit" value="" placeholder="请输入固定额度变动的值" >
                                    </div>
                                </div>

                                <div class="form-group col-md-2 " id="form_group_next_creditlimit">
                                    <label class="col-xs-12" for="next_creditlimit">修改后固定额度</label>
                                    <div class="col-sm-12">
                                        <div class="form-control-static" id="next_now_creditlimit"></div>
                                    </div>
                                </div>

                                <div class="form-group col-md-3 " id="form_group_account_period">
                                    <label class="col-xs-12" for="account_period">固定额度账期</label>
                                    <div class="col-sm-12">
                                        <input class="form-control" type="text" id="account_period" name="account_period" value="{notempty name='$data.account_period'}{$data.account_period}{/notempty}" placeholder="请输入固定额度账期" onkeyup="if(isNaN(value))execCommand('undo')" 6onafterpaste="if(isNaN(value))execCommand('undo')">
                                    </div>
                                </div>

                                <div class="form-group col-md-4 " id="form_group_temporary_creditlimit">
                                    <label class="col-xs-12" for="temporary_creditlimit">临时信用额度</label>
                                    <div class="col-sm-12">
                                        <input class="form-control" type="text" id="temporary_creditlimit" name="temporary_creditlimit" value="{$data.temporary_creditlimit}" placeholder="请输入临时信用额度" onkeyup="if(isNaN(value))execCommand('undo')" 6onafterpaste="if(isNaN(value))execCommand('undo')">
                                    </div>
                                </div>

                                <div class="form-group col-md-4 " id="form_group_temporary_time">
                                    <label class="col-xs-12">临时信用额度日期范围</label>
                                    <div class="col-md-12">
                                        <div class="input-daterange input-group" data-date-format="yyyy-mm-dd">
                                            <input class="form-control" type="text" id="temporary_time" name="temporary_time" value="{notempty name='$data.temporary_time'}{$data.temporary_time}{/notempty}" placeholder="{notempty name='$data.temporary_time'}{$data.temporary_time}{else/}开始时间{/notempty}">
                                            <span class="input-group-addon"><i class="fa fa-chevron-right"></i></span>
                                            <input class="form-control" type="text" id="temporary_endtime" name="temporary_endtime" value="{notempty name='$data.temporary_endtime'}{$data.temporary_endtime}{/notempty}" placeholder="{notempty name='$data.temporary_endtime'}{$data.temporary_endtime}{else/}结束时间{/notempty}">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group col-md-12">
                                    <div class="col-xs-12">
                                        <button class="btn btn-minw btn-primary ajax-post" target-form="form-builder" type="submit">
                                            提交                                        </button>
                                        <button class="btn btn-default" type="button" onclick="javascript:history.back(-1);return false;">
                                            返回                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

{/block}

{block name="script"}
<script src="/public/static/libs/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript">
    $(document)

        .off('blur','#creditlimit')
         .on('blur','#creditlimit',function(){
                    //只能输入数字
                    var creditlimit = $('#creditlimit').val();
                    var now_creditlimit=$("#now_creditlimit").text();
                    var reg1 = (/^([+-]?[\d]+[.]\d{0,2})$/gi).test(creditlimit);
                    var reg2 = (/^([+-]?[\d]+)$/gi).test(creditlimit);
                    if(reg1||reg2){
                        $(this).css('background',"#fff");
                        var next_now_creditlimit=parseFloat(creditlimit) +parseFloat(now_creditlimit);
                           $("#next_now_creditlimit").html(next_now_creditlimit) ;
                    }else{
                        $(this).val('');
                    }

                })
        App.initHelpers(["datepicker"]);
</script>
{/block}
